<template>
  <div class="post-list">
    <article v-for="post in list" :key="post._id" class="card mb-5 shadow-sm">
      <div class="card-body">
        <h4><router-link :to="`/posts/${post._id}`">{{ post.title }}</router-link></h4>
        <div class="row my-3 align-items-center">
          <div class="col-4">
            <img :src="post.image?.url" alt="" class="rounded-lg w-100" />
          </div>
          <div :class="{ 'col-8': post.image }">{{ post.excerpt }}</div>
        </div>
        <span>{{ post.createdAt }}</span>
      </div>
    </article>
  </div>
</template>

<script lang="ts">
import { defineComponent, PropType } from "vue";
// import { PostProps } from "@/testData"
import { PostProps } from "@/store";

export default defineComponent({
  props: {
    list: {
      type: Array as PropType<PostProps[]>,
      required: true,
    },
  },
  setup() {
    return {};
  },
});
</script>

<style>
.card-body h4 a {
  text-decoration: none;
}
</style>
